package com.dz.Controller;


import com.dz.domain.emp;
import com.dz.domain.searchEmp;
import com.dz.userService.impl.EmpServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@CrossOrigin
@RestController
public class userInfController {

    @Autowired
    EmpServiceImpl empService;

    @ResponseBody
    @PostMapping("/removeUser")
    public int removeUser(@RequestBody int empId){
        int rows = empService.removeUser(empId);
        System.out.println(rows);
        return rows;
    }

    /***
     * 搜索查询
     */
    @ResponseBody
    @PostMapping("/searchInfo")
    public emp searchInfo(@RequestBody searchEmp emp){
        emp empList = empService.findEmp(emp.getKeyword());
        return empList;
    }

    /**
     * 数据统计
     * */
    @ResponseBody
    @GetMapping("/queryInfo")
    public int[] queryInfo(){
        int[] list = new int[]{120,110,158,121,100,123};

        return list;
    }

    /**
     * 响应修改的用户信息
     * */
    @ResponseBody
    @PostMapping("/editUser")
    public boolean editUser(@RequestBody emp e){
        int rows = empService.updateEmp(e);
        boolean flag = true;
        if (rows == 1){
            return flag;
        }else {
            return !flag;
        }
    }

}
